{% extends 'projects/base_project.html' %}
{% load opencve_extras %}

{% block title %}{{ block.super }}{% endblock %}

{% block content_project %}

<div class="row">
    <div class="col-md-8">

        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">Activity Feed</h3>
            </div>
            <div class="box-body">
                {% if not changes %}
                <p class="alert alert-info">No activity yet.</p>
                {% else %}
                <ul class="timeline timeline-inverse">
                    {% for change in changes %}
                    <li class="time-label">
                        {% ifchanged change.created_at|date:"d b Y" %}
                        <span class="bg-blue bg-opencve">
                            {{ change.created_at|date:"d b Y" }}
                        </span>
                        {% endifchanged %}
                    </li>

                    <li>
                        {% if change|is_new_cve %}
                        <i class="fa fa-plus bg-red"></i>
                        {% else %}
                        <i class="fa fa-edit bg-blue"></i>
                        {% endif %}
                        <div class="timeline-item">
                            <span class="time" title="{{ change.created_at|date:'d b Y, H:i' }}"><i class="fa fa-clock-o"></i> {{ change.created_at|date:"H:i" }}</span>
                            <h3 class="timeline-header"><a href="{% url 'cve' cve_id=change.cve.cve_id %}">{{ change.cve.cve_id }}</a> <i>{% if change|is_new_cve %}is a new CVE{% else %}has changed{% endif %}</i> <a href="{% url 'change' cve_id=change.cve.cve_id id=change.id %}" class="btn-json-diff" data-toggle="tooltip" data-container="body" title="View the change details"><i class="fa fa-code"></i></a></h3>
                            <div class="timeline-body">
                                <p class="timeline-cve-summary">{{ change.cve.description }}</p>
                                {% include 'changes/change_events.html' %}
                            </div>
                        </div>
                    </li>
                    {% endfor %}

                </ul>
                {% endif %}

                {% if changes %}
                <div class="center">
                    <ul class="pagination">
                        {% if page_obj.has_previous %}
                            <li class="previous"><a href="{% url 'project' %}?{% query_params_url 'page' page_obj.previous_page_number %}">« prev </a></li>
                        {% endif %}
                        {% if page_obj.has_next %}
                            <li class="previous"><a href="{% url 'project' %}?{% query_params_url 'page' page_obj.next_page_number %}">next »</a></li>
                        {% endif %}
                    </ul>
                </div>
                {% endif %}
            </div>
        </div>

    </div>
    <div class="col-md-4">
        <div class="box box-primary">
            <div class="box-header">
                <div class="box-title">Subscriptions</div>
                <div class="box-tools pull-right">
                    <a class="btn btn-box-tool" href="{% url 'subscriptions' org_name=request.current_organization.name project_name=project.name %}" data-toggle="tooltip" data-container="body" data-placement="left" title="Manage subscriptions"><i class="fa fa-gears"></i></a>
                </div>
            </div>
            <div class="box-body box-subscriptions">
                {% include 'projects/includes/subscriptions.html' %}
            </div>
        </div>

        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">Last Reports</h3>
                <div class="box-tools pull-right">
                    <a class="btn btn-box-tool" href="{% url 'reports' org_name=request.current_organization.name project_name=project.name %}" data-toggle="tooltip" data-container="body" data-placement="left" title="See this project reports"><i class="fa fa-list-ul"></i></a>
                </div>
            </div>
            <div class="box-body">
                {% if reports %}
                <table class="table">
                    <thead>
                        <tr>
                            <th class="col-md-6">Date</th>
                            <th class="text-center">Number of Changes</th>
                        </tr>
                    </thead>
                    <tbody>
                    {% for report in reports %}
                    <tr>
                        <td><a href="{% url 'report' org_name=request.current_organization.name project_name=project.name day=report.day %}">{{ report.day|date:"D d M Y" }}</a></td>
                        <td class="text-center">{{ report.changes.count }}</td>
                    </tr>
                    {% endfor %}
                    </tbody>
                </table>
                {% else %}
                <p class="alert alert-info">No report available.</p>
                {% endif %}
            </div>
        </div>
    </div>
</div>

{% endblock %}
